package grailsforum

class VotesController {

    static allowedMethods = [

        votePost: 'POST',
        removeVotePost: 'POST'
    ]

    def votePost(){

        Vote vote = new Vote(user: User.get(session.user.id), post: Post.get(params.post))
        vote.save()

        render "ok"
    }

    def removeVotePost(){

        Vote vote = Vote.get(params.vote);
        vote.delete()

        render "ok"
    }
}
